﻿<Window x:Class="ResourceBlender.Express.WinMain"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:rbcore="clr-namespace:ResourceBlender.Core;assembly=ResourceBlender.Core"
    xmlns:loc="clr-namespace:ResourceBlender.Express"
    xmlns:converters="clr-namespace:ResourceBlender.Express.Converters"
    xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase" 
    Title="ResourceBlender Express" WindowStartupLocation="CenterScreen"
    MinHeight="300" Height="500"
    MinWidth="400" Width="600"
    Loaded="Window_Loaded"
    Style="{StaticResource {x:Type Window}}" Icon="/ResourceBlenderExpress;component/Resources/images/resourceblender.ico">
    <Window.Resources>
        <converters:LanguageCodeListStringifier x:Key="LanguageCodeListStringifier" />
        <converters:BundleNameStringifier x:Uid="converters:BundleNameStringifier_1" x:Key="BundleNameStringifier" />
        <converters:CanEditAppConverter x:Uid="converters:CanEditAppConverter_1" x:Key="CanEditAppConverter" />
        <Image x:Key="AutoTranslate_16" x:Shared="False" Source="pack://application:,,,/Resources/images/autotranslate_16.png" />
        <BitmapImage x:Key="arrow_right_16" UriSource="pack://application:,,,/Resources/images/arrow_right_16.png" />
        <BitmapImage x:Key="database_16" UriSource="pack://application:,,,/Resources/images/database_16.png" />
        <Image x:Key="Chart_16" x:Shared="False" Source="pack://application:,,,/Resources/images/chart_16.png" />
        <Image x:Key="Copy_16" x:Shared="False" Source="pack://application:,,,/Resources/images/copy_16.png" />
        <Image x:Key="DeleteApp_16" x:Shared="False" Source="pack://application:,,,/Resources/images/application_delete_16.png" />
        <Image x:Key="EditApp_16" x:Shared="False" Source="pack://application:,,,/Resources/images/application_edit_16.png" />
        <Image x:Key="Unused_16" x:Shared="False" Source="pack://application:,,,/Resources/images/unused_16.png" />
        <DataTemplate x:Key="SummaryApplication" DataType="{x:Type loc:ObservableApplication}">
            <Border x:Name="PART_Border" IsHitTestVisible="True" 
                    BorderThickness="1" CornerRadius="1">
                <Grid Margin="2">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    
                    <TextBlock Grid.Row="0" IsHitTestVisible="True" Grid.Column="0" Grid.ColumnSpan="2" FontWeight="Bold" Text="{Binding Value.DisplayName}" Style="{StaticResource HeadingFont}" Margin="0,0,0,5" />
                    <TextBlock Grid.Row="1" IsHitTestVisible="True" Grid.Column="0" Margin="0,0,5,0" FontWeight="Bold" Text="Bundles" Style="{StaticResource PaddedTextBlock}" />
                    <TextBlock Grid.Row="1" IsHitTestVisible="True" Grid.Column="1" TextWrapping="Wrap" Text="{Binding Value.Bundles,Converter={StaticResource BundleNameStringifier}}" Style="{StaticResource PaddedTextBlock}" />
                    <TextBlock Grid.Row="2" IsHitTestVisible="True" Grid.Column="0" Margin="0,0,5,0" FontWeight="Bold" Text="Languages" Style="{StaticResource PaddedTextBlock}" />
                    <TextBlock Grid.Row="2" IsHitTestVisible="True" Grid.Column="1" TextWrapping="Wrap" Text="{Binding Value.Languages,Converter={StaticResource LanguageCodeListStringifier}}" Style="{StaticResource PaddedTextBlock}" />
                    <WrapPanel Grid.Row="3" IsHitTestVisible="True" Grid.Column="0" Grid.ColumnSpan="2" Margin="5,1,5,5">
                        <loc:ImageButton Image="{StaticResource arrow_right_16}" ImageLocation="Right" Command="{x:Static loc:ResourceBlenderCommands.EditDefaultLanguage}" CommandParameter="{Binding Value}" IsEnabled="{Binding Converter={StaticResource CanEditAppConverter}}" ToolTipService.ShowOnDisabled="True" Text="Edit Default Language" />
                        <loc:ImageButton Image="{StaticResource arrow_right_16}" ImageLocation="Right" Command="{x:Static loc:ResourceBlenderCommands.EditAllLanguages}" CommandParameter="{Binding Value}" IsEnabled="{Binding Converter={StaticResource CanEditAppConverter}}" ToolTipService.ShowOnDisabled="True" Text="Edit All Languages" />
                    </WrapPanel>
            </Grid>
            </Border>
            <DataTemplate.Triggers>
                <DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type ListBoxItem}},Path=IsSelected}" Value="True">
                    <Setter TargetName="PART_Border" Property="Background" Value="{StaticResource SelectedTransparentBackgroundBrush}" />
                    <Setter TargetName="PART_Border" Property="BorderBrush" Value="{StaticResource LightBorderBrush}" />
                </DataTrigger>
            </DataTemplate.Triggers>
        </DataTemplate>
    </Window.Resources>
    
    <DockPanel LastChildFill="True">
        <Menu DockPanel.Dock="Top">
            <MenuItem Header="_File">
                <MenuItem Header="_Open">
                    <MenuItem Header="_Translation Database (*.rbt)" Command="loc:ResourceBlenderCommands.OpenRBT" />
                    <MenuItem Header="Managed _Resources File (*.resx)" Command="loc:ResourceBlenderCommands.OpenResx" />
                </MenuItem>
                <MenuItem Header="_Import">
                    <MenuItem Header="GNU _Portable Object (.po)" Command="loc:ResourceBlenderCommands.Import" CommandParameter="PO" />
                    <MenuItem Header="_Java (.properties)" Command="loc:ResourceBlenderCommands.Import" CommandParameter="Properties" />
                    <MenuItem Header="._NET Managed Resources (.resx)" Command="loc:ResourceBlenderCommands.Import" CommandParameter="Resx" />
                    <MenuItem Header="_Translation Database" Command="loc:ResourceBlenderCommands.Import" CommandParameter="TranslationDb" />
                    <MenuItem Header="_XML Backup" Command="loc:ResourceBlenderCommands.Import" CommandParameter="XML" />
                    <MenuItem Header="XML _Spreadsheet" Command="loc:ResourceBlenderCommands.Import" CommandParameter="XMLXLS" />
                </MenuItem>
                <MenuItem Header="_Export">
                    <MenuItem Header="_Translation Database" Command="loc:ResourceBlenderCommands.Export" CommandParameter="TranslationDb" />
                    <MenuItem Header="_XML Backup" Command="loc:ResourceBlenderCommands.Export" CommandParameter="XML" />
                    <MenuItem Header="XML _Spreadsheet" Command="loc:ResourceBlenderCommands.Export" CommandParameter="XMLXLS" />
                </MenuItem>
                <Separator />
                <MenuItem Header="_Templates" Command="loc:ResourceBlenderCommands.ShowTemplates" />
                <Separator />
                <MenuItem Header="Options" Command="loc:ResourceBlenderCommands.ShowOptions" InputGestureText="Alt+O" />
                <MenuItem Header="E_xit" Command="ApplicationCommands.Close" />
            </MenuItem>
            <MenuItem Header="_Resources">
                <MenuItem Header="_Automatic Translation" Command="loc:ResourceBlenderCommands.AutoTranslate" Icon="{StaticResource AutoTranslate_16}" />
                <MenuItem Header="Create _Variant" Command="loc:ResourceBlenderCommands.CreateVariant" />
                <MenuItem Header="_Duplicate Resources" Command="loc:ResourceBlenderCommands.ShowDuplicates" Icon="{StaticResource Copy_16}" />
                <MenuItem Header="_Edit Resources" Command="loc:ResourceBlenderCommands.ViewResourcesPrompt" />
                <MenuItem Header="Ge_nerate Resources" Command="loc:ResourceBlenderCommands.GenerateResources" />
                <MenuItem Header="Resource Summary" Command="loc:ResourceBlenderCommands.ShowSummary" Icon="{StaticResource Chart_16}"  />
                <MenuItem Header="_Unused Resources" Command="loc:ResourceBlenderCommands.ShowUnused" Icon="{StaticResource Unused_16}"  />
            </MenuItem>
            <MenuItem Header="_Help">
                <MenuItem Header="Help _Contents" Command="ApplicationCommands.Help" />
                <MenuItem Header="_Donate!" Click="btnDonate_Click" />
                <MenuItem Header="_About" Command="loc:ResourceBlenderCommands.ShowAbout" />
            </MenuItem>
        </Menu>
        <ToolBar x:Name="tlbMain" DockPanel.Dock="Top" VerticalAlignment="Top" HorizontalAlignment="Stretch" IsHitTestVisible="True" HorizontalContentAlignment="Left">
            <loc:ImageButton x:Name="btnApplications" Command="loc:ResourceBlenderCommands.ViewApplications" Text="Applications" Image="Resources/images/applications_32.png" ToolTip="Manage applications" Style="{StaticResource ToolBarButton}" />
            <loc:SplitButton x:Uid="loc:SplitButton_1" Style="{StaticResource SplitButton}" MainButtonLocation="Left">
                <loc:SplitButton.Button>
                    <loc:ImageButton x:Name="btnResources" Command="loc:ResourceBlenderCommands.ViewResourcesPrompt" Text="Resources" Image="Resources/images/resources_32.png" ToolTip="View and edit resources" Style="{StaticResource ToolBarButton}" />
                </loc:SplitButton.Button>
                <loc:SplitButton.MenuButton>
                    <loc:MenuButton x:Uid="loc:MenuButton_1" MenuLocation="Bottom" ToolTip="View and edit resources">
                        <loc:MenuButton.Menu>
                            <ContextMenu>
                                <MenuItem Header="Automatic Translation" Command="loc:ResourceBlenderCommands.AutoTranslate" Icon="{StaticResource AutoTranslate_16}" />
                                <MenuItem Header="Create Variant" Command="loc:ResourceBlenderCommands.CreateVariant" />
                                <MenuItem Header="Duplicate Resources" Command="loc:ResourceBlenderCommands.ShowDuplicates" Icon="{StaticResource Copy_16}" />
                                <MenuItem Header="Resource Summary" Command="loc:ResourceBlenderCommands.ShowSummary" Icon="{StaticResource Chart_16}"  />
                                <MenuItem Header="Unused Resources" Command="loc:ResourceBlenderCommands.ShowUnused" Icon="{StaticResource Unused_16}" />
                            </ContextMenu>
                        </loc:MenuButton.Menu>
                    </loc:MenuButton>
                </loc:SplitButton.MenuButton>
            </loc:SplitButton>
            <loc:ImageButton x:Name="btnGenerate" Command="loc:ResourceBlenderCommands.GenerateResources" Text="Generate" Image="Resources/images/generate_32.png" ToolTip="Create output files from resources" Style="{StaticResource ToolBarButton}" />
            <Separator  />
            <loc:ImageButton x:Name="btnTemplates" Command="loc:ResourceBlenderCommands.ShowTemplates" Text="Templates" Image="Resources/images/templates_32.png" ToolTip="Custom format templates" Style="{StaticResource ToolBarButton}" />
            <loc:ImageButton x:Name="btnOptions" Command="loc:ResourceBlenderCommands.ShowOptions" Text="Options" Image="Resources/images/settings_32.png" Style="{StaticResource ToolBarButton}" />
        </ToolBar>
        <StatusBar DockPanel.Dock="Bottom" Height="24">
            <DockPanel LastChildFill="True">
                <Image DockPanel.Dock="Left" Source="{StaticResource database_16}" />
                <TextBlock x:Name="lblDb" DockPanel.Dock="Left" TextTrimming="CharacterEllipsis" TextWrapping="NoWrap" />
                <TextBlock x:Name="lblStatus" DockPanel.Dock="Right" Visibility="Hidden" TextTrimming="CharacterEllipsis" TextWrapping="NoWrap">Loading Summary</TextBlock>
                <ProgressBar x:Name="prgStatus" DockPanel.Dock="Left" IsIndeterminate="True" MinWidth="40" Visibility="Hidden" />
            </DockPanel>
        </StatusBar>
        <TabControl DockPanel.Dock="Top" x:Name="tbcSummary" Background="Transparent" BorderThickness="0">
            <TabItem Height="0">
                <ListBox x:Name="lstApps" Style="{StaticResource InvisibleListBox}" ItemTemplate="{StaticResource SummaryApplication}" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.CanContentScroll="False">
                    <ListBox.ContextMenu>
                        <ContextMenu>
                            <MenuItem Header="Edit" Icon="{StaticResource EditApp_16}" Command="loc:ResourceBlenderCommands.Edit" />
                            <MenuItem Header="Delete" Icon="{StaticResource DeleteApp_16}" Command="loc:ResourceBlenderCommands.Delete" />
                            <MenuItem Header="Create Copy" Icon="{StaticResource Copy_16}" Command="loc:ResourceBlenderCommands.DuplicateApplication" CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=ContextMenu}, Path=PlacementTarget.SelectedItem}" />
                            <Separator/>
                            <MenuItem Header="Generate" Command="loc:ResourceBlenderCommands.GenerateResources" CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=ContextMenu}, Path=PlacementTarget.SelectedItem}" />
                            <MenuItem Header="Resource Summary" Icon="{StaticResource Chart_16}" Command="loc:ResourceBlenderCommands.ShowSummary" CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=ContextMenu}, Path=PlacementTarget.SelectedItem.Value}" />
                        </ContextMenu>
                    </ListBox.ContextMenu>
                </ListBox>
            </TabItem>
            <TabItem Height="0">
                <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center">No applications have been added, click Applications to add one.</TextBlock>
            </TabItem>
            <TabItem Height="0">
                <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" MaxWidth="300">
                    <TextBlock Margin="2" TextAlignment="Center" TextWrapping="Wrap">A database connection could not be established</TextBlock>
                    <TextBlock x:Name="txtDBError" Margin="2,2,2,10" TextAlignment="Center" TextWrapping="Wrap"  />
                    <loc:ImageButton Margin="2" MinWidth="160" Image="{StaticResource database_16}" ImageLocation="Right" Command="loc:ResourceBlenderCommands.ShowOptions" Text="Create a new database" />
                    <loc:ImageButton Margin="2" MinWidth="160" Image="{StaticResource arrow_right_16}" ImageLocation="Right" Command="loc:ResourceBlenderCommands.OpenRBT" Text="Open a translation database" />
                </StackPanel>
            </TabItem>
        </TabControl>
    </DockPanel>
</Window>
